package com.example.router

import android.content.Context
import com.alibaba.android.arouter.facade.Postcard
import com.alibaba.android.arouter.facade.annotation.Interceptor
import com.alibaba.android.arouter.facade.callback.InterceptorCallback
import com.alibaba.android.arouter.facade.template.IInterceptor
import com.bw.base.conts.BaseConst
import com.tencent.mmkv.MMKV

@Interceptor(priority = 4, name = "路由参数拦截器")
class RouteParamsInterceptor:IInterceptor {

    private lateinit var mContext:Context
    override fun init(context: Context?) {
        context?.let {
            mContext = it
        }
    }

    override fun process(postcard: Postcard?, callback: InterceptorCallback?) {

        val traceId = MMKV.defaultMMKV().decodeString("accessId", "00a5a3682f7840a8803ab10eb0434cbf")
        if (!traceId.isNullOrEmpty()){
            postcard?.withString("accessId",traceId)
        }
        callback?.onContinue(postcard)
    }
}